package com.yanxu.bak;

import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetSocketAddress;
import java.nio.charset.StandardCharsets;

/**
 * @author 折戟沉沙铁未销
 * @version V1.0
 * @date 2025-06-04-2025
 * @Description: 这里用一句话描述这个类的作用
 */
public class provider {
    public static void main(String[] args) throws IOException {
        DatagramSocket datagramSocket = new DatagramSocket();
        String msg="hello world";
        byte[] msgBytes = msg.getBytes(StandardCharsets.UTF_8);
        DatagramPacket datagramPacket = new DatagramPacket(msgBytes, msgBytes.length);
        datagramPacket.setAddress(new InetSocketAddress("127.0.0.1",8888).getAddress());
        datagramPacket.setPort(8888);
        datagramSocket.send(datagramPacket);
        System.out.println("数据发送完毕!!!");
    }
}